<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="../css/setting.css" />
</head>

<body class="white">
	<div class="mui-content">
	    <div class="forgettop"><img src="../icon/forget1.png" alt="" /></div>
	    <div class="forms">
		    	<div class="inputBox">
		    		<input type="text" name="" id="phone" placeholder="您的手机帐号" disabled="disabled" class="phoneIcon" />
		    	</div>
		    	<div class="inputBox vercode mui-clearfix">
		    		<input type="text" name="" class="codes" placeholder="验证码" />
		    		<button type="button" class="bexta-btn bexta-btn-red mui-btn" id="getCode">获取验证码</button>
		    	</div>
	    </div>
	    <div class="mui-content-padded" style="margin-top: 20px;">
	   		<button type="button" class="bexta-btn bexta-btn-red mui-btn mui-btn-block enter" >下一步</button>
	   </div>
	</div>
<script src="../js/mui.js"></script>
<script src="../js/vue.min.js"></script>
<script src="../js/bexta.js"></script>
<script type="text/javascript">
	var apps , views, user;
	mui.init({
		beforeback:function(){
			if( plus.webview.currentWebview().opener().id == 'login' ){
				bexta.setStatus(true)
			}
		}
	});
	mui.plusReady(function () {
		views = bexta.getWebview();
		var stype;
		if( views.type == 'forget' ){
			document.querySelector('#phone').disabled = false;
			document.querySelector('#getCode').addEventListener('tap', function(){
				var phone = document.querySelector('#phone').value;
				if( !check.phone(phone) ){
					mui.toast("手机号错误");
					return ;
				}
		    		var f = mui('#getCode').button('loading');
				bexta.ajax(''+api.send_msg, function(res){
					if( res.isError == 0 ){
						mui.toast(res.msg);
						bexta.countDown(90, function(m){
							if( m <=1  ){
								f.reset();
							}else{
								f.setText(m + '秒');
							}

						});
					}
				},{data:{mobile:phone, type:3}},function(){
					f.reset();
				});
		    });
			var title="输入新密码";
			
		}else{
			 document.querySelector('.phoneIcon').value = bexta.getStorage(USER).mobile;
			 var title = '重设密码';
			 document.querySelector('#getCode').addEventListener('tap', function(){
		    		var f = mui('#getCode').button('loading');
					bexta.ajax(''+api.send_msg, function(res){
						if( res.isError == 0 ){
							mui.toast(res.msg);
							bexta.countDown(90, function(m){
								if( m <=1  ){
									f.reset();
								}else{
									f.setText(m + '秒');
								}
	
							});
						}
					},{data:{mobile:bexta.getStorage(USER).mobile, type:2, uid:bexta.getStorage(USER).uid}},function(){
						f.reset();
					});
		    });
		}
		document.querySelector('.enter').addEventListener('tap', function(){
		    		var code = document.querySelector('.codes').value;
		    		if( code == '' ){
		    			mui.toast('验证码错误');
		    			return ;
		    		}
		    		bexta.openWithTitle({
		    			id:'forget2',
		    			url:'forget2.html',
		    			extras:{
		    				codes:code,
		    				type:views.type,
		    				phone:document.querySelector('#phone').value
		    			}
		    		},{
		    			title:{
		    				text:title
		    			}
		    		})
		    });
		
		
	   
	});
</script>
</body>
</html>